if ( !arg[A_PN] ) arg[A_PN] = (LONG)pn; /* corrects a Bug in Readargs(): /M arrays ignore preset defaults :-( */
if ( !arg[A_LIN] ) if ( GetVar( "HOSTNAME", hostname, 30, 0 ) != -1 ) arg[A_LIN] = (LONG)hostname;
if ( giveDefault ) { showdefaults(argd); result = 0; } else
{ /* now one indent level is missing! (I'm lazy *and* don't like goto's :) */
if ( arg[A_STE] || IsInteractive( Input() ) ) if ( !( mystderr = Open("*", MODE_OLDFILE) ) ) CUP("Sorry for the requester,\nbut: Unable to open '*' (stderr)!\n", 99);
/* where to put the report of serial communication and sana status */
if ( ! arg[A_RPF] ) { if ( !arg[A_QUIET] ) repfile = Output(); }
else if ( ! ( repfile = Open((UBYTE *)arg[A_RPF], MODE_NEWFILE ) ) ) CUP1("Unable to create reportfile '%s'", arg[A_RPF], 21);
if ( ! ReadConfig( (UBYTE *)arg[A_SCF], *(LONG *)arg[A_SAU], &serpara) ) CUP("Error reading sana configuration file!", 22);
if ( ( arg[A_AA] || !arg[A_NRC] ) && serpara.listen2CD )
msg("\
Warning: If you don't remove the 'CD' paramter from\n\
the sana configuration file, you will'\n\
have to manually 'online' the sana device \n\
on incomming calls.\n\
(To avoid this warning use NORECONNECT or NRC)",
*(LONG *)arg[A_SAU]);
/* open slipdevice */
if ( ! ( sanaport = CreateMsgPort() ) ) CUP("Unable to create message port for sana device.", 23);
if ( ! ( sanaIOReq = CreateIORequest(sanaport, sizeof(*sanaIOReq) ) ) ) CUP ("Unable to create IORequest for sanal line.", 24);
if ( sanaopenerr = OpenDevice((UBYTE *)arg[A_SAD], *(LONG *)arg[A_SAU], (struct IORequest *)sanaIOReq, 0L)) CUP1("Unable to open sana device '%s'.",arg[A_SAD], 25);
/**********************************************/
/* Sana ONLINE */
/**********************************************/
if ( ABBREV((UBYTE *)arg[A_CMD], "ON" ) )
{ putOnline = TRUE; result = 0; }
/**********************************************/
/* Sana OFFLINE */
/**********************************************/
else if ( ABBREV((UBYTE *)arg[A_CMD], "OF" ) )
{
sanaIOReq->ios2_Req.io_Command = S2_OFFLINE;
if ( DoIO( (struct IORequest *)sanaIOReq) ) CUP("Error in making sana device offline.", 26);
if ( repfile ) Write(Output(), WS("Sana offline\n"));
putOnline = FALSE; result = 0;
} else {
/* now another indent level more missing! (I'm lazy *and* don't like goto's :) */
/* get receivebuffer */
if ( ! ( rxbuffer = AllocMem(RXBUFSIZE, 0) ) ) CUP("Unable get memory for receive buffer.", 27);
/* open timer device */
if ( ! ( timeport = CreateMsgPort() ) ) CUP("Unable to create message port for timer device.", 28);
if ( ! ( timereq = (struct timerequest *)CreateIORequest( timeport, sizeof( struct timerequest ) ) ) ) CUP ("Unable to create IORequest for timer device.", 29);
if ( timeopenerr = OpenDevice(TIMERNAME, UNIT_VBLANK, (struct IORequest *)timereq, 0L) ) CUP("Timer device did not open.", 30);
/* open serial device */
if ( ! ( serialport = CreateMsgPort() ) ) CUP("Unable to create message port for serial line.", 31);
serialport->mp_Node.ln_Name = SERPORTNAME;
serialport->mp_Node.ln_Pri = -1;
AddPort(serialport);
if ( ! ( serialIOReq = (struct IOExtSer *) CreateIORequest( serialport, sizeof(struct IOExtSer) ) ) ) CUP ("Unable to create IORequest for serial line.", 32);
if ( repfile ) Write(Output(), WS("Sana offline\n"));
if ( DoIO( (struct IORequest *)sanaIOReq) ) CUP("Error in sana offline for opening serial device.", 33);
if ( seropenerr = OpenDevice(serpara.serDevName, serpara.serUnit, (struct IORequest *)serialIOReq, 0) ) CUP("Serial device did not open (even with slip offline!).", 34 );
putOnline = TRUE;
}
if ( !initSerialLine(&serpara) ) CUP("Error initalizing serial line", 39 )
result = 10; /* so far, so good .. No fatal errors anymore */